package com.cslg.ac.demo.dao.user.person;

import com.cslg.ac.demo.dao.user.po.person.PersonInfoPO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 尚未检测 2.7
 *     int id;
 String name;
 int gender;
 String birthday;
 String address;
 String codeCertificate;
 String idCard;
 String phone;
 String email;
 int accpet;
 int grade; 因为目前还不知道要什么，需要的时候再把想到的加上去
 *
 */

@Mapper
public interface PersonInfoDAO {
    String PERSONINFO_TABLE = "e_p_account_info";
    String SELECT_FIELD = "id,name,gender,city,phone,email,accept,grade,love_value loveValue," +
            "synopsis,idCard,realName,image";

    @Insert({"insert into", PERSONINFO_TABLE, "(id,phone) values (#{id},#{phone})"})
    void insert(PersonInfoPO personInfoPO);

    @Select({"select ",SELECT_FIELD," from ",PERSONINFO_TABLE," where id = #{id}"})
    PersonInfoPO selectById(@Param("id") int id);

    @Select({"select ",SELECT_FIELD," from ",PERSONINFO_TABLE," where phone = #{phone}"})
    PersonInfoPO selectByPhone(@Param("phone") String phone);

    @Update({"update ",PERSONINFO_TABLE,"set name = #{name},gender = #{gender}","where phone = #{phone}"})
    void updateBaiscByPhone(PersonInfoPO personInfoPO);

    @Update({"update ",PERSONINFO_TABLE," set image = #{image},name = #{name},email = #{email},grade = #{grade},phone = #{phone},accept = #{accept},love_Value = #{loveValue}," +
            "gender = #{gender},synopsis = #{synopsis},city = #{city},idCard = #{idCard},realName = #{realName} where id = #{id}"})
    void updateAllById(PersonInfoPO personInfoPO);

    @Update({"update ",PERSONINFO_TABLE," set name = #{name},gender = #{gender}," +
            "synopsis = #{synopsis},city = #{city} where phone = #{phone}"})
    void updateInfoByPhone(PersonInfoPO personInfoPO);
    @Select({"select ",SELECT_FIELD," from ",PERSONINFO_TABLE," where email = #{email}"})
    PersonInfoPO selectByMail(String email);

    @Select({"select id from ",PERSONINFO_TABLE,"where email = #{email}"})
    Integer selectIdByMail(String email);

    @Select({"select id from ",PERSONINFO_TABLE,"where name like concat(concat('%',#{name}),'%') limit #{offset}, #{num}"})
    Integer[] selectIdByName(@Param("name") String name,@Param("offset") int offset, @Param("num") int num);

    @Select({"select id from ",PERSONINFO_TABLE,"where city like concat(concat('%',#{city}),'%') limit #{offset}, #{num}"})
    Integer[] selectByCity(@Param("city")String city,@Param("offset") int offset, @Param("num")int num);



}
